﻿@model FortuneCat.WebUI.Models.BalanceListViewModel
           
<script type="text/javascript">
    $(function () {
        //$("table.grid tbody tr:odd").addClass("odd");
        $("#balanceList a.button").button();
    });
</script>

<div class="toolbar top ui-widget ui-widget-content ui-corner-bl ui-corner-br">
    <ul>
        <li class="left"><a href="@Url.Action("Save", "Home")" id="add" class="button">新增</a></li>
        <li class="right stat balance">结余：@Model.TotalBalance.ToString("N2")</li>
        <li class="right stat payment">支出：@Model.TotalPayment.ToString("N2")</li>
        <li class="right stat receipt">收入：@Model.TotalReceipt.ToString("N2")</li>
    </ul>
    <div class="ui-helper-clearfix"></div>
</div>

<table border="0" cellpadding="0" cellspacing="0" class="grid">
    <thead>
        <tr>
            <th>日期</th>
            <th style="text-align: right">收入</th>
            <th style="text-align: right">支出</th>
            <th>原由</th>
            <th>收支人</th>
            <th class="actions">操作</th>
        </tr>
    </thead>
    <tbody>
    @foreach (var balance in Model.Balances) { 
        <tr>
            <td>@balance.BalanceDate.ToLongDateString()</td>
            <td style="text-align: right" class="receipt ui-state-highlight">@(balance.Amount > 0 ? Math.Abs(balance.Amount).ToString("N2") : String.Empty)</td>
            <td style="text-align: right" class="payment ui-state-error">@(balance.Amount < 0 ? Math.Abs(balance.Amount).ToString("N2") : String.Empty)</td>
            <td>@balance.Reason</td>
            <td>@balance.User.Nickname</td>
            <td class="actions">
                <a href="@Url.Action("Save", "Home", new { id = balance.Id })" class="button modify">修改</a>
                <a href="@Url.Action("Delete", "Home", new { id = balance.Id })" class="button delete">删除</a>
            </td>
        </tr>
    }
    </tbody>
</table>

@Html.PageLinks(Model.PagingInfo, x => Url.Action("List", new {page = x}))
